#include <stdio.h>
#include <ctype.h>
#include <string.h>

int main() {
    char s1[1000], s2[1000];
    char line2[1000], line3[1000];
    
    // 读取第一行的两个字符串
    scanf("%s %s", s1, s2);
    getchar(); // 读取换行符
    
    // 读取第二行和第三行
    fgets(line2, sizeof(line2), stdin);
    fgets(line3, sizeof(line3), stdin);
    
    // 去掉换行符
    line2[strcspn(line2, "\n")] = 0;
    line3[strcspn(line3, "\n")] = 0;
    
    // 1. 统计三行
    int upper = 0, lower = 0, digit = 0, space = 0, other = 0;
    
    // 统计第一行（s1 和 s2 以及它们之间的空格）
    for (int i = 0; s1[i]; i++) {
        char c = s1[i];
        if (isupper(c)) upper++;
        else if (islower(c)) lower++;
        else if (isdigit(c)) digit++;
        else if (c == ' ') space++;
        else other++;
    }
    
    // 统计s1和s2之间的空格
    space++; // 这就是关键！第一行两个字符串之间的空格
    
    for (int i = 0; s2[i]; i++) {
        char c = s2[i];
        if (isupper(c)) upper++;
        else if (islower(c)) lower++;
        else if (isdigit(c)) digit++;
        else if (c == ' ') space++;
        else other++;
    }
    
    // 统计第二行
    for (int i = 0; line2[i]; i++) {
        char c = line2[i];
        if (isupper(c)) upper++;
        else if (islower(c)) lower++;
        else if (isdigit(c)) digit++;
        else if (c == ' ') space++;
        else other++;
    }
    
    // 统计第三行
    for (int i = 0; line3[i]; i++) {
        char c = line3[i];
        if (isupper(c)) upper++;
        else if (islower(c)) lower++;
        else if (isdigit(c)) digit++;
        else if (c == ' ') space++;
        else other++;
    }
    
    printf("%d %d %d %d %d\n", upper, lower, digit, space, other);
    
    // 2. 比较 s1 和 s2
    int len1 = strlen(s1);
    int len2 = strlen(s2);
    int min_len = len1 < len2 ? len1 : len2;
    int diff_sum = 0;
    int key = 0;
    
    for (int i = 0; i < min_len; i++) {
        diff_sum += (s1[i] - s2[i]);
    }
    
    if (diff_sum == 0) {
        if (len1 == len2) key = 0;
        else if (len1 < len2) key = 0;
        else key = 0;
    } else {
        key = diff_sum;
    }
    
    printf("%d\n", key);
    
    // 3. 解密第二行
    for (int i = 0; line2[i]; i++) {
        char c = line2[i];
        if (c == ' ') {
            putchar(' ');
        } else if (isupper(c)) {
            int shift = key;
            char new_c = ((c - 'A' + shift) % 26 + 26) % 26 + 'A';
            putchar(new_c);
        }
    }
    putchar('\n');
    
    // 4. 解密第三行
    for (int i = 0; line3[i]; i++) {
        char c = line3[i];
        if (c == ' ') {
            putchar(' ');
        } else if (isupper(c)) {
            int shift = key;
            char new_c = ((c - 'A' + shift) % 26 + 26) % 26 + 'A';
            putchar(new_c);
        }
    }
    putchar('\n');
    
    return 0;
}